﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<List<Sys.WebRes.Publish.Areas.Admin.Models.FileSysModel>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    浏览文件
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
<link href="<%=Url.Content("~/Content/fileIcon/css.css") %>" rel="stylesheet" type="text/css" />
<style type="text/css">
    #selWin
    {
        width:100%;
        height:200px;
    }
    .fileList
    {
        width:100%;
    }
    .fileList li
    {
        float:left;
        width:180px;
        height:22px;
        white-space:nowrap;
    }
    .fileList li label
    {
        overflow:hidden;
        white-space:nowrap;
    }
    .selFile{}
</style>
<script type="text/javascript" language="javascript">
    $().ready(function () {
        $('#selWin').panel({
            width: 561,
            height: 200,
            noheader: false,
            border: true,
            title: '　',
            tools: [
            {
                iconCls: 'icon-ok',
                title: "全选",
                handler: function () {
                    $(".selFile").each(function () {
                        this.checked = true;
                    });
                }
            }, {
                iconCls: 'icon-cancel',
                title: "取消全选",
                handler: function () {
                    $(".selFile").each(function () {
                        this.checked = false;
                    });
                }
            }, {
                iconCls: 'icon-back',
                title: "根目录",
                handler: function () {
                    window.history.go(-1);
                }
            }, {
                iconCls: 'icon-reload',
                title: "刷新",
                handler: function () {
                    window.location.reload();
                }
            }]
        });
    });

    function selectFiles() {
        var files = [];
        $(".selFile").each(function () {
            if (this.checked) {
                files.push([this.id, this.path, this.ext]);
            }
        });

        window.frameElement.okHandler(files);

        return files;
    }

    function cancel() {
        window.frameElement.cancelHandler();
    }
</script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="BodyContent" runat="server">
<body>
<div id="selWin" class="easyui-panel">
    <ul class="fileList">
    <% foreach (var item in Model) { %>
        <%if (item.IsFolder){ %>
        <li class="<%= Html.Encode(item.Type) %>" >
            <a href="<%=Url.RouteUrl("FileSys") + "/" + item.FileName%>">
                <%= Html.Encode(item.FileName) %>
            </a>
        </li>
        <%}else{ %>
        <li>
            <input type="checkbox" path="<%=item.Path %>" ext="<%=item.Type %>" id="<%=item.Title %>" class="selFile" />
            <label class="<%= Html.Encode(item.Type) %>" for="<%=item.Title %>"><%=item.FileName%></label>
        </li>
        <%}%>
    <% } %>
    </ul>
</div>
<div class="operDiv" style="text-align:right; height:22px;">
    <a class="easyui-linkbutton" href="javascript:void(0)" onclick="selectFiles()">选择</a>
    <a class="easyui-linkbutton" href="javascript:void(0)" onclick="cancel()">取消</a>
</div>
</body>
</asp:Content>